package com.design.patterns;

class Source1 {
    public void method1() {
        System.out.println("This is original method...");
    }
}

interface Targetable1 {

    /**
     * 与原类中的方法相同
     */
    public void method1();

    /**
     * 新类的方法
     */
    public void method2();
}

class Wrapper implements Targetable1 {

    private Source1 source;

    public Wrapper(Source1 source) {
        super();
        this.source = source;
    }

//    @Override
    public void method1() {
        source.method1();
    }

//    @Override
    public void method2() {
        System.out.println("This is the targetable method...");
    }
}

//对象适配器模式
public class AdapterPattern1 {
    public static void main(String[] args) {
        Source1 source = new Source1();
        Targetable1 targetable = new Wrapper(source);
        targetable.method1();
        targetable.method2();
    }
}
